Imports System.Collections.Generic
Imports System.Linq
Imports System.Web

#Region "using"
Imports System.Data
Imports QUANLY.DTO
#End Region
Public Class TOUR_DIADIEMDAO
    Inherits AbstractDAO
    Public Sub New(ByVal strPath As [String])
        MyBase.New(strPath)
    End Sub

    Public Function SelectAll() As DataSet
        Dim ds As DataSet
        Try
            ds = New DataSet()
            MyBase.sql = "usp_TOUR_DIADIEM_SelectAll"
            MyBase.FillDataSet(ds, "TOUR_DIADIEM")
            Return ds
        Catch e As System.Exception
            Throw New Exception(e.Message, e.InnerException)
        Finally
            MyBase.CleanUpObject()
        End Try
    End Function

    Public Function SelectByID(ByVal id As Integer) As DataSet
        Dim ds As DataSet
        Try
            ds = New DataSet()
            MyBase.sql = "usp_TOUR_DIADIEM_SelectByID"
            MyBase.InitializeCommand()
            MyBase.AddParameter("@ID", SqlDbType.Int, 1000, id)
            MyBase.FillDataSet(ds, "TOUR_DIADIEM")
            Return ds
        Catch e As System.Exception
            Throw New Exception(e.Message, e.InnerException)
        Finally
            MyBase.CleanUpObject()
        End Try
    End Function

    Public Function Insert(ByVal obj As TOUR_DIADIEMDTO) As Boolean
        Try
            MyBase.sql = "usp_TOUR_DIADIEM_Insert"
            MyBase.InitializeCommand()
            MyBase.AddParameter("@IDTour", SqlDbType.Int, 1000, obj.IDTour)
            MyBase.AddParameter("@IDDiaDiem", SqlDbType.Int, 1000, obj.IDDiaDiem)
            Return ExecuteStoredProcedure()
        Catch
            Return False
        End Try
    End Function

    Public Function Update(ByVal obj As TOUR_DIADIEMDTO) As Boolean
        Try
            MyBase.sql = "usp_TOUR_DIADIEM_Update"
            MyBase.InitializeCommand()
            MyBase.AddParameter("@ID", SqlDbType.Int, 1000, obj.ID)
            MyBase.AddParameter("@IDTour", SqlDbType.Int, 1000, obj.IDTour)
            MyBase.AddParameter("@IDDiaDiem", SqlDbType.Int, 1000, obj.IDDiaDiem)
            Return ExecuteStoredProcedure()
        Catch
            Return False
        End Try
    End Function

    Public Function Delete(ByVal id As Integer) As Boolean
        Try
            MyBase.sql = "usp_TOUR_DIADIEM_Delete"
            MyBase.InitializeCommand()
            MyBase.AddParameter("@ID", SqlDbType.Int, 1000, id)
            Return ExecuteStoredProcedure()
        Catch
            Return False
        End Try
    End Function

    Public Function DeleteByIDTour(ByVal idtour As Integer) As Boolean
        Try
            MyBase.sql = "usp_TOUR_DIADIEM_DeleteByIDTour"
            MyBase.InitializeCommand()
            MyBase.AddParameter("@IDTour", SqlDbType.Int, 1000, idtour)
            Return ExecuteStoredProcedure()
        Catch
            Return False
        End Try
    End Function

    Public Function SelectByIDLoTrinh(ByVal idlotrinh As Integer) As DataSet
        Dim ds As DataSet
        Try
            ds = New DataSet()
            MyBase.sql = "usp_TOUR_DIADIEM_SelectByIDLoTrinh"
            MyBase.InitializeCommand()
            MyBase.AddParameter("@IDLoTrinh", SqlDbType.Int, 1000, idlotrinh)
            MyBase.FillDataSet(ds, "TOUR_DIADIEM")
            Return ds
        Catch e As System.Exception
            Throw New Exception(e.Message, e.InnerException)
        Finally
            MyBase.CleanUpObject()
        End Try
    End Function

    Public Function SelectByIDDiaDiem(ByVal iddiadiem As Integer) As DataSet
        Dim ds As DataSet
        Try
            ds = New DataSet()
            MyBase.sql = "usp_TOUR_DIADIEM_SelectByIDDiaDiem"
            MyBase.InitializeCommand()
            MyBase.AddParameter("@IDDiaDiem", SqlDbType.Int, 1000, iddiadiem)
            MyBase.FillDataSet(ds, "TOUR_DIADIEM")
            Return ds
        Catch e As System.Exception
            Throw New Exception(e.Message, e.InnerException)
        Finally
            MyBase.CleanUpObject()
        End Try
    End Function

    Public Function SelectByIDTour(ByVal idtour As Integer) As DataSet
        Dim ds As DataSet
        Try
            ds = New DataSet()
            MyBase.sql = "usp_TOUR_DIADIEM_SelectByIDTour"
            MyBase.InitializeCommand()
            MyBase.AddParameter("@IDTour", SqlDbType.Int, 1000, idtour)
            MyBase.FillDataSet(ds, "TOUR_DIADIEM")
            Return ds
        Catch e As System.Exception
            Throw New Exception(e.Message, e.InnerException)
        Finally
            MyBase.CleanUpObject()
        End Try
    End Function
End Class
